﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Ecreate.Business;
using Ecreate.Model;

namespace Ecreate.Web
{
    public partial class ProductPage : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ProductService service = new ProductService();
                Product model = new Product();
                model.Pid = int.Parse(this.Request.QueryString["pid"]);
                model = service.getProductByID(model);
                txtPname.Text = model.Pname;
                string[] desc = model.Pdescription.Split(new string[]{"\r\n"},StringSplitOptions.None);
                string li = "";
                foreach (string s in desc)
                {
                    li += "<li>" + s + "</li>";
                }
                string ul = "<ul>" + li + "</ul>";
                Literal1.Text = ul;
                txtPrice.Text = model.Price.ToString();
                imgPreview.ImageUrl = "~" + model.Pimageurl;
            }
        }
    }
}
